package com.pounds.control;

import com.pounds.pojo.Work;
import com.pounds.service.WorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("peaceful/work")
public class WorkControl {

    @Autowired
    private WorkService workService;

    @GetMapping("select")
    public List<Work> getWorkList() {
        return workService.getWorkList();
    }

    @GetMapping("new")
    public String addWork(int user, String event, String need, String note) {
        return workService.addWork(user, event, need, note);
    }

    @GetMapping("delete")
    public String deleteWork(int id) {
        return workService.deleteWork(id);
    }

    @GetMapping("update")
    public String updateWork(int id, int user, String event, String need, String note) {
        return workService.updateWork(id, user, event, need, note);
    }
}
